package com.tom.architect02.ui10.day11;

import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.widget.LinearLayout;
import androidx.annotation.Nullable;

/**
 * Added by Tom on 2024/06/07.
 */
public class TouchViewGroup extends LinearLayout {

    public TouchViewGroup(Context context) {
        this(context, null);
    }
    public TouchViewGroup(Context context, @Nullable AttributeSet attrs) {
        this(context, attrs, 0);
    }
    public TouchViewGroup(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    // 事件分发
    @Override
    public boolean dispatchTouchEvent(MotionEvent ev) {
        Log.e("TAG0607", "ViewGroup dispatchTouchEvent-- " + ev.getAction());
        return super.dispatchTouchEvent(ev);
    }

    // 事件拦截
    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        Log.e("TAG0607", "ViewGroup onInterceptTouchEvent-- " + ev.getAction());
        return super.onInterceptTouchEvent(ev);
    }

    // 事件触摸。
    @Override
    public boolean onTouchEvent(MotionEvent event) {
        Log.e("TAG0607", "ViewGroup onTouchEvent-- " + event.getAction());
        return super.onTouchEvent(event);
    }

    // 是否允许拦截事件。
    @Override
    public void requestDisallowInterceptTouchEvent(boolean disallowIntercept) {
        super.requestDisallowInterceptTouchEvent(disallowIntercept);
    }
}
